#pragma once

#include "base/core/singleton.h"
#include "Common/AccountDefine.h"
#include "base/core/object_pool.h"
#include "ProtoBuffer/AllProtocol.h"
#include "Common/Timer/TimerAxis.h"
#include <math.h>
#include "Common/MessageDispatch/IMessageDispatch.h"
#include "Common/TeamDefine.h"
#include "Common/Event/Event.h"

class Player;

//逻辑服的组队管理器
class GTeamManager : public IServerMessageHandler,
					 public IEventExecuteSink,
					 public ManualSingleton < GTeamManager >
{
public:
	bool 				Init();
	void 				UnInit();

	//////////////////////////////  IServerMessageHandler ////////////////////////////////////////////
	virtual void		onServerMessage(uint32_t actionId, RECV_PACKAGE &package);
	virtual const char* getServerHandlerDebugInfo(void){ return "GTeamManager::onServerMessage"; }
	virtual void		OnExecute(uint16_t nEventID, uint64_t nSrcID, uint8_t bySrcType, void *pContext, int32_t nLen);

public:
	bool				OnUpdateTeamNotify(RECV_PACKAGE &package);
	bool				OnLeaderPosInfo(RECV_PACKAGE &package);
	bool				OnUpdateTeamClosenessNotify(RECV_PACKAGE &package);
	bool				OnStarSoulSend(RECV_PACKAGE &package);
	bool				OnWLCallMemsRsp(RECV_PACKAGE &package);

	//根据亲密度等级获取经验加成
	uint32_t			GetTeamExpAdd(uint32_t closenessLv);
	uint32_t			GetTeamAttackAdd(uint32_t closendssLv);
	//获取玩家附近的队伍玩家的平均等级，先这样处理，后面不满足再来看如何处理 add by wangxx 20170922
	uint32_t			GetNearTeamAverageLevel(Creature * pCreature);
	//队员取消跟随
	void				CancelFllow(uint32_t teamId, SET_UINT64 setCid);

public:


public:
	GTeamManager();
	virtual ~GTeamManager();
};

#define g_MakeGTeamMgr() (GTeamManager::Instance())
#define g_GetGTeamMgr()  (GTeamManager::GetInstance())
#define g_DelGTeamMgr()  (GTeamManager::Destroy())